const sql = require("../../mysql");

module.exports = async ctx => {
  try {
    const { id, name } = ctx.request.body;

    await sql.Vfile.update(
      { name },
      {
        where: {
          id,
          userId: ctx.request.userId
        }
      }
    );

    ctx.body = {
      code: 0,
      msg: "成功"
    };
  } catch (error) {
    console.log(error);
    ctx.response.status = 200;

    ctx.body = {
      code: -1,
      msg: error.errors ? error : error.errors[0].message
    };
  }
};
